Unit deposec;

Interface

Uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, ExtCtrls, Grids, Wwdbigrd, Wwdbgrid, Db, ADODB, StdCtrls, Mask,
  wwdbedit, Wwdotdot, Wwdbcomb, siComp;

Type
  Tfdeposec = Class(TForm)
    StatusBar1: TStatusBar;
    Panel1: TPanel;
    Panel2: TPanel;
    wwDBGrid1: TwwDBGrid;
    kayit: TADOQuery;
    DataSource1: TDataSource;
    Button1: TButton;
    Button2: TButton;
    Procedure FormCreate(Sender: TObject);
    Procedure Button2Click(Sender: TObject);
    Procedure FormClose(Sender: TObject; Var Action: TCloseAction);
    Procedure Button1Click(Sender: TObject);
    Procedure wwDBGrid1FieldChanged(Sender: TObject; Field: TField);
  Private
    { Private declarations }
  Public
    { Public declarations }
  End;

Var
  fdeposec: Tfdeposec;
  bak: Boolean;

Implementation

Uses data, cariaral, ucariara2, ana1;

{$R *.DFM}

Procedure Tfdeposec.FormCreate(Sender: TObject);
Begin
  bak := true;
End;

Procedure Tfdeposec.Button2Click(Sender: TObject);
Begin
  close;
End;

Procedure Tfdeposec.FormClose(Sender: TObject; Var Action: TCloseAction);
Begin
  action := cafree;
  fdeposec := Nil;
End;

Procedure Tfdeposec.Button1Click(Sender: TObject);
Begin
  If kayit.State In [Dsedit] Then
  Begin
    kayit.Post;
    kayit.Close;
    kayit.open;
  End
  Else
  Begin
    kayit.Close;
    kayit.open;
  End;

End;

Procedure Tfdeposec.wwDBGrid1FieldChanged(Sender: TObject; Field: TField);
Begin
  If ((field.FieldName = 'urtekdepo') Or (field.FieldName = 'urrmadepo') Or
    (field.FieldName = 'urdepo') Or (field.FieldName = 'urcikis') Or
    (field.FieldName = 'urundepo')) And (bak = true) Then
  Begin
    dm.Cariara.Close;
    dm.Cariara.SQL.Clear;
    dm.Cariara.SQL.Add('select distinct carikod, KARGOKOD,carikodu, istihbarat,Tekyetkili, CTipi=(select adi from dbo.carituru where id=Tipi), FirmaAdi, Soyadi, ilce, Sehir,telefon3,KARGOADI=(select top 1 Ad from tbl_KargoTanim where ID=KARGOKOD) from Cari');

    dm.Cariara.SQL.Add('where (CariKod>0) and (tipi=''Depo'')');
    dm.Cariara.Open;
    If (dm.CariAra.RecordCount = 1) Then
    Begin
      bak := False;
      Field.Value := dm.CariAra.fieldbyname('Carikod').asinteger;
      wwDBGrid1.RefreshDisplay;
    End
    Else
    Begin
      If (dm.cariAra.RecordCount > 1) Then
      Begin
        If Not assigned(fCariaraL) Then
          fCariAraL := tfCariAral.create(self);
        If fCariAraL.showmodal = mrOk Then
        Begin
          bak := False;
          Field.Value := dm.CariAra.fieldbyname('Carikod').asinteger;
          wwDBGrid1.RefreshDisplay;
        End;
      End;
    End;
    bak := true;
  End;
End;

End.